package com.ebt.m.wiki;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;

import com.ebt.m.commons.buscomponent.listview.BaseRecyclerAdapter;
import com.ebt.m.commons.buscomponent.listview.BaseListView;
import com.ebt.m.commons.buscomponent.listview.BasePresenter;
import com.ebt.m.utils.UIHelper;
import com.ebt.m.commons.buscomponent.listview.ISectionFactory;

/**
 * Created by wanglu on 2017/10/18.
 */

public class SpecProductFilterView extends BaseListView<SpecProductPresenter> {

    public static final int TAG_VIEW_YTPE = 0;
    public static final int HISTORY_VIEW_TYPE = 1;
    public static final int BRAND_VIEW_TYPE = 2;


    private int from;

    public SpecProductFilterView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SpecProductFilterView(Context context) {
        this(context, null);
    }

    public SpecProductFilterView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mRefreshLayout.setRefreshNeeded(false);
    }

    @Override
    protected ISectionFactory createViewFactory() {
        return viewType -> {
            if (viewType == TAG_VIEW_YTPE) {
                return new SectionProductFilterTag(getContext());
            } else if (viewType == HISTORY_VIEW_TYPE || viewType == BRAND_VIEW_TYPE) {
                SectionProductFilterBrand sectionProductFilterBrand = new SectionProductFilterBrand(getContext());
                sectionProductFilterBrand.needClose = from == 2;
                return sectionProductFilterBrand;
            }
            return null;
        };
    }

    @Override
    protected SpecProductPresenter createPresenter() {
        return new SpecProductPresenter(getContext(), this);
    }

    @Override
    public void loadNext() {

    }

    @Override
    public void update(Object... args) {
        super.update(args);
        from = (int) args[1];
        mPresenter.loadNew(args);
    }

    @Override
    protected boolean createFootView() {
        return false;
    }

}
